#!/usr/bin/env python2.7
#-*- coding:utf-8 -*-
#Author='He Rensheng'
#Email='hrs323@126.com'

# import cv2
import random
import shutil
import os
# im = cv2.imread('/media/hrs/新加卷/PictcureLibrary/trainlibrary/HatAndMan/VOC2007/JPEGImages/rBOilFia5OKALEWsAAVKAViDnv4863.jpg')
# im_orig = im.astype(np.float32, copy=True)
# print(im_orig)
# # cv2.imwrite('/home/hrs/installations/pva-faster-rcnn/data/demo/office-clothes.jpg', im)
# # #cv2.imshow('/home/hrs/installations/pva-faster-rcnn/data/demo/office-clothes.jpg', dd)
# objpath = '/media/hrs/新加卷/PictcureLibrary/trainlibrary/HatAndMan/test_result/20171128-test/'
# savepath = '/media/hrs/新加卷/PictcureLibrary/trainlibrary/HatAndMan/test_result/20171128-test/100-to-check'
# fileList = os.listdir('/media/hrs/新加卷/PictcureLibrary/trainlibrary/HatAndMan/test_result/20171128-test')
# fileList.remove('not_detect')
#
# ind = random.sample(xrange(1,len(fileList)), 100)
# os.chdir(objpath)
# for i in range(100):
#     shutil.copy(fileList[ind[i]], savepath)


objpath = '/media/hrs/新加卷/PictcureLibrary/trainlibrary/HatAndMan/VOC2007/JPEGImages'
savepath = '/media/hrs/新加卷/PictcureLibrary/trainlibrary/HatAndMan/VOC2007/100-to-check'
fileList = [line.strip() + '.jpg' for
            line in open('/media/hrs/新加卷/PictcureLibrary/trainlibrary/HatAndMan/VOC2007/ImageSets/Main_20171128/train.txt')]
if not os.path.isdir(savepath):
    os.makedirs(savepath)

ind = random.sample(xrange(1, len(fileList)), 100)
os.chdir(objpath)
for i in range(100):
    shutil.copy(fileList[ind[i]], savepath)
